﻿// -----------------------------------------------------------------------
// <copyright file="ChartWriter.cs" company="">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace ClearLines.Stocks.UserInterface.Utilities
{
   using Microsoft.Office.Interop.Excel;

   /// <summary>
   /// TODO: Update summary.
   /// </summary>
   public class ChartWriter
   {
      public static Chart CreateLineChart(Chart chart, SeriesData seriesData)
      {
         chart.ChartType = XlChartType.xlLine;
         AppendSeries(chart, seriesData);
         return chart;
      }

      public static Chart CreateHistogram(Chart chart, SeriesData seriesData)
      {
         chart.ChartType = XlChartType.xlColumnStacked;
         AppendSeries(chart, seriesData);
         return chart;       
      }

      public static Chart AppendSeries(Chart chart, SeriesData seriesData)
      {
         var seriesCollection = (SeriesCollection)chart.SeriesCollection();
         var series = seriesCollection.NewSeries();

         series.Name = seriesData.Name;
         series.Values = seriesData.Values;
         series.XValues = seriesData.XValues;

         return chart;
      }
   }
}
